/** @jsxImportSource @emotion/react */
import * as React from "react";
import {CCell, Cell, Table, TableBody, TableRow, Text,} from "customize-easy-ui-component";
import {RepLink,} from "../../common/base";
import {usePrefixDataTable} from "../../hook/usePrefixData";
import {multiCheckMany} from "../../common/general";

const lst减温方式=["喷淋式减温","表面式减温","混合式减温"];
const lst汽机式=["凝汽式","背压式"];
export const daL给水处=[['氧化性全挥发处理','氧化挥'],['还原性全挥发处理','还原挥']];
export const daL炉水处=[['炉水固体碱化剂处理','炉固碱化'],['炉水全挥发处理','炉全挥发']];
export const daL给水系=[['有铜系统','有铜系'],['无铜系统','无铜系'],['过热蒸汽压力≥5.9 MPa，凝汽器管为铜管，其他换热器管为钢管','凝铜他钢']];
/*加载报错！： 导致这里 config设备概况 无法移入到orcBase.tsx;
* */
export const config设备概况 = [
  [[{pr: '使用单位', span: 4, t: '名  称'}, '_$使用单位',],],
  [[{t: '安装地址'}, '_$设备使用地点'], ],
  [[{t: '安全管理部门'}, '_$分支机构'], ['联系人', '_$单位联系人']],
  //台账？：水质人员数量；
  [[{t: '联系电话'}, '_$使用单位电话'], ['持证水处理作业人员数', {n: '持证水人', u: '人'}]],
  [[{pr: '锅炉基本情况', span: 4, t: '制造单位'}, '_$制造单位', ], ['锅炉型号', '_$型号']],
  [[{t: '额定蒸发量'}, '_$额定蒸发量', 't/h'], ['单位内编号', '_$单位内部编号']],
  [[{t: '额定压力'}, '_$额定压力', 'MPa'], ['锅炉使用证号', '_$使用证号',]],
  [[{t: '过热器减温方式'}, {n: '减温式', t: 'l', l: lst减温方式}], ['汽机型式', {n: '汽机式', t: 'l', l: lst汽机式}]],

  //水处理方法"WATER_CLFF": "锅外水处理,锅内水处理",
  [[{pr: '水处理情况', span: 4, t: '水处理方式'}, '_$水处理式',], ],
        //存储是在multiCheckMany回调函数的{ names:[] }
  [[{t: '给水处理'},'',multiCheckMany(daL给水处,'给水处理')]],
  [[{t: '炉水处理'},'',multiCheckMany(daL炉水处,'炉水处理')]],
  [[{t: '给水系统'},'',multiCheckMany(daL给水系,'给水系统',{width:300,column:4})]],
];

export const 检验结论报告 = ({orc, rep, theme}: { orc: any, rep: any, theme: any }
) => {
  const renderUpper=usePrefixDataTable({config: config设备概况, orc, rep, slash:true});
  return <>
    <Text variant="h2" css={{textAlign: 'center', "@media print": {pageBreakBefore: 'always',},
    }}>电站锅炉水汽质量检验报告</Text>
    <Text css={{display: 'flex', flexDirection: 'row-reverse', marginRight: '2rem'
    }}>报告编号：{rep.isp?.no}</Text>
    <Table id='Survey' fixed={ ["3%", "14.1%", "38%", "9%", "5.1%","%"]  }
                    css={{borderCollapse: 'collapse'}} tight miniw={800}>
      <TableBody>
        <RepLink rep={rep} tag={'Survey'}>
          {renderUpper}
          <TableRow >
            <CCell colSpan={2}>检验依据</CCell>
            <Cell colSpan={4}>
              TSG 11-2020《锅炉安全技术规程》<br/>
              GB/T 12145-2016《火力发电机组及蒸汽动力设备水汽质量》
            </Cell>
          </TableRow>
        </RepLink>
      </TableBody>
    </Table>
    <Table id='Conclusion' fixed={ ["8.5%","33%", "%"] } css={{borderCollapse: 'collapse'}} tight miniw={800}>
      <TableBody>
        <RepLink rep={rep} tag={'Conclusion'}>
          <TableRow>
            <CCell>检验情况</CCell>
            <Cell colSpan={2}><div css={{minHeight: '4rem', whiteSpace: 'pre-wrap',marginLeft: '0.2rem'}}>
              {orc.结论说明 ?? '／'}
            </div></Cell>
          </TableRow>
          <TableRow>
            <CCell rowSpan={2}>检验结论</CCell>
            <CCell colSpan={2}>根据NB/T 10937-2022《锅炉水（介）质处理检验导则》：</CCell>
          </TableRow>
          <TableRow>
            <CCell><Text variant="h1" css={{fontSize:'1.8rem'}}>{orc.检验结论}</Text></CCell>
            <CCell>
              <div css={{minHeight: '3rem', whiteSpace: 'pre-wrap',display:'flex',flexDirection:'column-reverse',textAlign:'end'}}>
                <Text css={{marginRight:'2rem'}}>下次检验日期为：&nbsp; {orc.新下检日 || '／'}</Text>
              </div>
            </CCell>
          </TableRow>
        </RepLink>
      </TableBody>
    </Table>
  </>;
};
